package com.itheima.goods.controller.user;


import com.itheima.goods.pojo.Category;
import com.itheima.goods.service.CategoryService;
import com.itheima.result.Result;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userCategoryController")
@RequestMapping("/user/category")
@Api(tags = "C端-分类接口")
@Slf4j
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    /**
     * 用户端条件查询分类
     * @param type
     * @return
     */
    @GetMapping("/list1")
    public Result<List<Category>> list(@RequestParam Long type){
        log.info("{} ",type);
       List<Category> categories= categoryService.selectByType(type);
       return Result.success(categories);
    }

    @GetMapping("/list")
    public Result<List<Category>> list1(){

        List<Category> categories= categoryService.all();
        return Result.success(categories);
    }


}
